from django.contrib.auth.models import User
from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models



class BaseInformationModel(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='profile_baseinformation')
    name = models.CharField(max_length=50, verbose_name='姓名')
    gender = models.CharField(max_length=10, choices=[('男', '男'), ('女', '女')], verbose_name='性别')
    birthday = models.DateField(verbose_name='出生日期')
    phone = models.CharField(max_length=20, verbose_name='联系电话')
    email = models.EmailField(verbose_name='电子邮箱')
    location = models.CharField(max_length=100, verbose_name='所在地区')
    personal_description = models.TextField(verbose_name='个人描述', blank=True, null=True)

class EducationExperienceModel(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='profile_educationexperience')
    DEGREE_CHOICES = [
        ('专科', '专科'),
        ('本科', '本科'),
        ('硕士', '硕士'),
        ('博士', '博士')
    ]
    school = models.CharField('学校名称', max_length=100)
    major = models.CharField('专业', max_length=50)
    degree = models.CharField('学历', max_length=10, choices=DEGREE_CHOICES)
    start_date = models.DateField('入学时间')
    end_date = models.DateField('毕业时间')
    gpa = models.FloatField(
        'GPA',
        null=True,
        blank=True,
        validators=[MinValueValidator(0), MaxValueValidator(4)]
    )
    description = models.TextField('在校表现', max_length=500, blank=True)
class WorkExperienceModel(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='profile_workexperience')
    company_name = models.CharField('公司名称', max_length=100)
    position = models.CharField('职位', max_length=50)
    department = models.CharField('部门', max_length=50)
    start_date = models.DateField('入职时间')
    end_date = models.DateField('离职时间')
    responsibilities = models.TextField('工作描述', max_length=500, blank=True)


class AwardModel(models.Model):
    user= models.ForeignKey(User, on_delete=models.CASCADE, related_name='profile_award',null=True)
    AWARD_LEVEL_CHOICES = [
        ('校级', '校级'),
        ('市级', '市级'),
        ('省级', '省级'),
        ('国家级', '国家级'),
        ('国际级', '国际级'),
    ]

    award_name = models.CharField('奖项名称', max_length=100)
    award_level = models.CharField('获奖级别', max_length=20, choices=AWARD_LEVEL_CHOICES)
    award_date = models.DateField('获奖时间')
    award_organization = models.CharField('颁发机构', max_length=100)
    award_description = models.TextField('奖项描述', blank=True)


class SkillModel(models.Model):
    user=models.ForeignKey(User,on_delete=models.CASCADE,related_name='profile_skill')
    SKILL_LEVEL_CHOICES = [
        ('了解', '了解'),
        ('熟悉', '熟悉'),
        ('精通', '精通'),
        ('专家', '专家'),
    ]

    name = models.CharField(max_length=100, verbose_name="技能名称")
    level = models.CharField(
        max_length=20,
        choices=SKILL_LEVEL_CHOICES,
        verbose_name="熟练程度"
    )
    description = models.TextField(blank=True, null=True, verbose_name="技能描述")
class ProjectModel(models.Model):
    user= models.ForeignKey(User, on_delete=models.CASCADE, related_name='profile_project',null=True)
    project_name = models.CharField(max_length=100, verbose_name="项目名称")
    project_role = models.CharField(max_length=100, verbose_name="担任角色")
    start_date = models.DateField(verbose_name="开始时间")
    end_date = models.DateField(null=True, blank=True, verbose_name="结束时间")
    project_description = models.TextField(verbose_name="项目描述")
    responsibilities = models.TextField(verbose_name="个人职责")
    technologies = models.CharField(
        max_length=255,
        blank=True,
        verbose_name="使用技术",
        help_text="多个技术用逗号分隔"
    )


class JobIntentionModel(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='profile_jobintention')
    JOB_NATURE_CHOICES = [
        ('', '请选择'),
        ('全职', '全职'),
        ('兼职', '兼职'),
        ('实习', '实习'),
    ]

    SALARY_CHOICES = [
        ('', '请选择'),
        ('面议', '面议'),
        ('2k-5k', '2k-5k'),
        ('5k-8k', '5k-8k'),
        ('8k-12k', '8k-12k'),
        ('12k-15k', '12k-15k'),
        ('15k-20k', '15k-20k'),
        ('20k-30k', '20k-30k'),
        ('30k以上', '30k以上'),
    ]

    JOIN_TIME_CHOICES = [
        ('', '请选择'),
        ('随时', '随时'),
        ('一周内', '一周内'),
        ('一个月内', '一个月内'),
        ('三个月内', '三个月内'),
        ('待定', '待定'),
    ]

    expected_position = models.CharField(max_length=100, verbose_name="期望职位")
    job_nature = models.CharField(
        max_length=10,
        choices=JOB_NATURE_CHOICES,
        verbose_name="工作性质"
    )
    expected_location = models.CharField(
        max_length=100,
        verbose_name="期望城市",
        help_text="可填写多个意向城市，用逗号分隔"
    )
    expected_salary = models.CharField(
        max_length=20,
        choices=SALARY_CHOICES,
        verbose_name="期望薪资"
    )
    industry = models.CharField(
        max_length=100,
        blank=True,
        verbose_name="期望行业"
    )
    join_time = models.CharField(
        max_length=20,
        choices=JOIN_TIME_CHOICES,
        verbose_name="可入职时间"
    )
    job_description = models.TextField(
        blank=True,
        verbose_name="补充说明"
    )